﻿<!--/************************************************************************************  
' Copyright (C) 2009 Anthony Bouch (http://www.58bits.com) under the terms of the
' Microsoft Public License (Ms-PL http://www.codeplex.com/precode/license)
'***********************************************************************************/-->
    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FiftyEightBits.PreCode"
    >
    <Style TargetType="{x:Type local:CloseButton}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:CloseButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="Timeline1">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Timeline2">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>                       
                    </ControlTemplate.Resources>

                    <Grid Width="16" Height="16">
                        <Border x:Name="NormalBorder" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="#666" BorderThickness="0" CornerRadius="2">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                    <GradientStop Offset="1" Color="#FF343434"/>
                                    <GradientStop Offset="0.5" Color="#FF858585"/>
                                    <GradientStop Offset="0.5" Color="#FF6D6D6D"/>
                                    <GradientStop Offset="0" Color="#FFDBDBDB"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border x:Name="HoverBorder" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="#666" BorderThickness="0" CornerRadius="2">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                    <GradientStop Offset="1" Color="#FFCC3434"/>
                                    <GradientStop Offset="0.5" Color="#FFCC8585"/>
                                    <GradientStop Offset="0.5" Color="#FFCC6D6D"/>
                                    <GradientStop Offset="0" Color="#FFCCDBDB"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Path HorizontalAlignment="Center" VerticalAlignment="Center" Data="F1 M 0,0 L 6,6" Stroke="#DDD" StrokeMiterLimit="1.0" StrokeThickness="1.0"/>
                        <Path HorizontalAlignment="Center" VerticalAlignment="Center" Data="F1 M 6,0 L 0,6" Stroke="#DDD" StrokeMiterLimit="1.0" StrokeThickness="1.0"/>
                    </Grid>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource Timeline2}"/>
                            </Trigger.ExitActions>
                        </Trigger>                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>

            </Setter.Value>
        </Setter>
    </Style>    
</ResourceDictionary>
